package com.jie.order.service;


import com.jie.feign.client.UserClient;
import com.jie.feign.entity.User;
import com.jie.order.entity.Order;
import com.jie.order.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private UserClient userClient;


    public Order queryOrderById(Long orderId) {
        // 1.查询订单
        Order order = orderMapper.findById(orderId);
        //2、利用Feign远程调用
        User user = (User)userClient.findById(order.getUserId());
        //3、存入order
        order.setUser(user);
        // 4.返回
        return order;
    }

}
